//
//  MapBasicDemoViewController.m
//  FMDemoBaseMap
//
//  Created by fengmap on 16/10/17.
//  Copyright © 2016年 fengmap. All rights reserved.
//
//  基础地图显示
//  简介：离线地图加载、在线地图加载；离线主题加载、在线主题加载；地图加载过程的回调方法；

#import "MapBasicDemoViewController.h"
#import "FMMapKit.h"

@interface MapBasicDemoViewController () <FMKMapViewDelegate>
{
    FMKMapView *_mapView;
}

@end

@implementation MapBasicDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 离线地图加载
    NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"jlai-cyds-museum02" ofType:@"fmap"];
    _mapView = [[FMKMapView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-64) path:dataPath delegate:self];
    [self.view addSubview:_mapView];
    
    // 在线地图加载
//    _mapView = [[FMKMapView alloc] initWithFrame:CGRectMake(0, 64, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height-64) ID:@"10347" delegate:self autoUpgrade:YES];
//    [self.view addSubview:_mapView];
    
    // 离线主题加载
    // 地图主题如果不设置，则SDK默认加载FMBundle.bundle中名称为2001的主题数据。
//    [_mapView setThemeWithLocalPath:[FMBUNDLE pathForResource:@"2001.theme" ofType:nil]];
    NSString *themePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"jlai-cyds-museum02/jlai-cyds-museum02.theme"];
    [_mapView setThemeWithLocalPath:themePath];
    
    // 在线主题加载
//    [_mapView setThemeWithID:@"1003"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - FMKMapViewDelegate
/*!
 @brief 地图加载完成
 @param mapview 地图View对象
 */
- (void)mapViewDidFinishLoadingMap:(FMKMapView *)mapView {
    NSLog(@"地图加载完成");
}
/*!
 @brief 地图加载失败
 @param mapView 地图View
 @param error 错误信息
 */
- (void)mapViewDidFailLoadingMap:(FMKMapView *)mapView withError:(NSError *)error {
    NSLog(@"地图加载失败-%@", error);
}

@end
